<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./Promise.js?a=1"></script>
    <script>
        // 1- Promise.race
        const p1 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve(1);
            },10)
        })
        const p2 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve(2);
            },200)
        })
        const p3 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                resolve(3);
            },50)
        })
        const p4 = new Promise((resolve,reject)=>{
            setTimeout(()=>{
                reject(4);
            },30)
        })

        const p =  Promise.race([p1,p2,p3,p4]);
        console.log(p);// 失败,值4
      
    </script>
</body>
</html>